/*
 * This file is part of freewm.
 *
 * freewm is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * freewm is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with freewm.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "incs.h"
#include "logger.h"

// logger globals.
int LOGGER_ENABLED = 0;

// Write logging information to console.
int logger(const char *format, ...)
{
	if (!LOGGER_ENABLED) return 0;
	
	char buffer[512];
	va_list ap;
	
	va_start(ap, format);
	vsnprintf(buffer, sizeof(buffer), format, ap);
	va_end(ap);

	printf(":: %s\n", buffer);
	return 1;
}

// Enable logging.
void logger_enable(void)
{
	LOGGER_ENABLED = 1;
}

// Disable logging.
void logger_disable(void)
{
	LOGGER_ENABLED = 0;
}
